﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CuitWinTabList.cs" company="">
//   
// </copyright>
// <summary>
//   The cuit win tab list.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace UITest.CUIT.CuitControls.WinControls
{
    using System.Collections.Generic;

    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UITesting.WinControls;

    /// <summary>
    ///     The cuit win tab list.
    /// </summary>
    public class CuitWinTabList : CuitWinControl<WinTabList>
    {
        #region Constructors and Destructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="CuitWinTabList" /> class.
        /// </summary>
        public CuitWinTabList()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinTabList"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        public CuitWinTabList(UITestControl testControl)
            : base(testControl)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinTabList"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        public CuitWinTabList(UITestControl testControl, string searchProperties)
            : base(testControl, searchProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinTabList"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        /// <param name="filterProperties">
        /// The filter properties.
        /// </param>
        public CuitWinTabList(UITestControl testControl, string searchProperties, string filterProperties)
            : base(testControl, searchProperties, filterProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinTabList"/> class.
        /// </summary>
        /// <param name="wrappedControl">
        /// The wrapped control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        public CuitWinTabList(ICuitControlBase wrappedControl, string searchProperties)
            : base(wrappedControl, searchProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinTabList"/> class.
        /// </summary>
        /// <param name="wrappedControl">
        /// The wrapped control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        /// <param name="filterProperties">
        /// The filter properties.
        /// </param>
        public CuitWinTabList(ICuitControlBase wrappedControl, string searchProperties, string filterProperties)
            : base(wrappedControl, searchProperties, filterProperties)
        {
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets or sets the selected index.
        /// </summary>
        public int SelectedIndex
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.SelectedIndex;
            }

            set
            {
                this._control.WaitForControlReady();
                this.WriteTestOutput(value.ToString());
                this._control.SelectedIndex = value;
            }
        }

        /// <summary>
        ///     Gets the tab spinner.
        /// </summary>
        public UITestControl TabSpinner
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.TabSpinner;
            }
        }

        /// <summary>
        ///     Gets the tabs.
        /// </summary>
        public UITestControlCollection Tabs
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.Tabs;
            }
        }

        /// <summary>
        ///     Gets the tabs as cui te.
        /// </summary>
        public List<CuitWinTabList> TabsAsCUITe
        {
            get
            {
                this._control.WaitForControlReady();
                var list = new List<CuitWinTabList>();
                foreach (WinTabPage control in this._control.Tabs)
                {
                    var tab = new CuitWinTabList();
                    tab.WrapReady(control);
                    list.Add(tab);
                }

                return list;
            }
        }

        #endregion
    }
}